package org.aplikator.client.local.widgets;

import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import org.aplikator.client.shared.descriptor.PropertyDTO;

import java.io.Serializable;

public class LabelFieldWidget<T extends Serializable> extends DataFieldBase implements DataField<T> {
    private TextBox box = new TextBox();

    public LabelFieldWidget(String caption, PropertyDTO property) {
        super(caption, property);
        controls.add(box);
        box.setEnabled(false);
        //box.addStyleName(PaneWidgetResources.INSTANCE.css().formData());

        /*if (property.getRefferedThrough() != null) {
            this.setEnabled(false);
        } */

    }

    public void setValue(T value) {
        box.setTitle(value != null? value.toString():"");
    }

    public T getValue() {
        return null;
    }

    public HandlerRegistration addValueChangeHandler(@SuppressWarnings("rawtypes") ValueChangeHandler handler) {
        return null;//box.addValueChangeHandler(handler);
    }

    public void setEnabled(boolean enabled) {
    }

    public void setDirty(boolean dirty) {
        super.setDirty(dirty);
    }

}
